package com.my.netty.promote.util;

import java.nio.charset.StandardCharsets;

public class ByteUtils {

    public static byte[] fillBytes(char c, int len, int cap) {
        assert len <= cap;

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < len; i++) {
            sb.append(c);
        }
        for (int i = len; i < cap; i++) {
            sb.append('_');
        }
        return sb.toString().getBytes(StandardCharsets.UTF_8);
    }

    public static String makeString(char c, int len) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < len; i++) {
            sb.append(c);
        }
        return sb.toString();
    }

    public static String makeStringLine(char c, int len) {
        return makeString(c, len) + '\n';
    }
}
